home *** CD-ROM | disk | FTP | other *** search
- page
- page 84,132
- title -- PFANEL.ASM -- PC Front Panel Simulation
- cseg segment para public 'CODE'
- org 100H
- assume cs:cseg,ds:cseg
- start:
- jmp initialize
-
- dspflg db 0
- dspseg dw 0
- curcol dw 0
- old_timer dd ?
- old_prtsc_io dd ?
- remove_msg label byte
- db 'FPANEL has been successfully removed from memory.'
- db 0dh,0ah,'$'
- rem_err_msg label byte
- db 'FPANEL was not removed properly! '
- db 'Reboot system to completely remove it.'
- db 0dh,0ah,'$'
-
- timer_int proc far
- sti
- pushf
- assume ds:nothing
- call old_timer
- push es
- push ds
- push bp
- mov bp,sp
- call timer
- pop bp
- pop ds
- pop es
- iret
- timer_int endp
-
- timer proc near
- assume cs:cseg,ds:cseg
- push ax
- push bx
- push cx
- push dx
- push si
- push di
- push ds
- mov bx,cs
- mov ds,bx
- xor bx,bx
- mov cs:curcol,bx
- ; The stack looks like this:
- ; New stack since bp saved
- ; [BP] word Old value of BP
- ; [BP+2] word Value of DS reg.
- ; [BP+4] word Value of ES reg.
- ; [BP+6] word Offset of calling address
- ; [BP+8] word Segment of calling address
- ; [BP+10] word flags at interrupt
- mov si,offset ipreg
- call dstring
- mov ax,word ptr ss:[bp+8] ; seg of addr
- call dsword
- call dcolon
- mov ax,word ptr ss:[bp+6] ; Offset of addr
- call dsword
- cmp byte ptr dspflg,0
- jz enddsp
- mov si,offset flgreg
- call dstring
- mov ax,word ptr ss:[bp+10]
- and ax,0fd5H
- call dsword
- mov si,offset ssreg
- call dstring
- mov ax,ss
- call dsword
- mov si,offset esreg
- call dstring
- mov ax,word ptr ss:[bp+4]
- call dsword
- mov si,offset dsreg
- call dstring
- mov ax,word ptr ss:[bp+2]
- call dsword
- enddsp:
- pop ds
- pop di
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- timer endp
-
- ; AX contains singleword to be displayed
- dsword proc near
- push ax ;Save low byte temporarily
- mov al,ah ;Move high byte to low byte
- call dbyte ;Display high byte
- pop ax ;Restore low byte
- call dbyte ;Display low byte
- ret
- dsword endp
-
- ; AL contains byte to be displayed
- dbyte PROC NEAR
- PUSH CX
- PUSH AX
- MOV CX,4
- AND AL,0F0H
- SHR AL,CL
- CALL NYBBLE_TO_HEX_DIGIT
- CALL DCHAR
- POP AX
- CALL NYBBLE_TO_HEX_DIGIT
- CALL DCHAR
- POP CX
- RET
- dbyte ENDP
-
- ;_____________________________________________________________________________;
- ; This procedure converts a nybble (4 bits) to an ASCII (hex) character. ;
- ; ;
- ; AL nybble to be converted ;
- ; Returns: AL ASCII character (hex digit) ;
- ;_____________________________________________________________________________;
- NYBBLE_TO_HEX_DIGIT PROC NEAR
- AND AL,0FH
- ADD AL,'0'
- CMP AL,'9'
- JLE NYBBLE_END
- ADD AL,'A'-':'
- NYBBLE_END: RET
- NYBBLE_TO_HEX_DIGIT ENDP
-
- ; Display a colon
- dcolon proc near
- mov al,':'
- call dchar
- ret
- dcolon endp
-
- ; Display string pointer to by SI
- dstring proc near
- nxtchr:
- cmp byte ptr cs:[si],0
- je strdone
- mov al,byte ptr cs:[si]
- call dchar
- inc si
- jmp nxtchr
- strdone:
- ret
- dstring endp
-
- dspmsg proc near
- push ax
- push dx
- push ds
- push cs
- pop ds
- mov dx,si
- mov ah,9
- int 21h
- pop ds
- pop dx
- pop ax
- ret
- dspmsg endp
- ; Display the character contained in AL
- dchar proc near
- push ax
- push bx
- push ds
- mov bx,cs:dspseg
- mov ds,bx
- mov bx,cs:curcol
- mov [bx],al
- inc bx
- inc bx
- mov cs:curcol,bx
- pop ds
- pop bx
- pop ax
- ret
- dchar endp
-
-
- control_int proc far
- sti
- push ax
- push dx
- push di
- push ds
- cbw
- shl ax,1
- mov di,ax
- jmp word ptr optstab[di]
- optstab:
- dw offset resints
- dw offset setint08
- dw offset iponly
- dw offset fulldsp
- dw offset setabort
- exit:
- sti
- pop ds
- pop di
- pop dx
- pop ax
- iret
-
- iponly:
- mov byte ptr cs:dspflg,0
- jmp exit
-
- fulldsp:
- mov byte ptr cs:dspflg,1
- jmp exit
-
- setint08:
- cli
- mov ax,cs
- mov ds,ax
- mov dx,offset timer_int
- mov al,08H
- mov ah,25H
- int 21H
- jmp exit
-
- resints:
- cli
- mov dx,cs:word ptr old_timer
- mov ax,cs:word ptr old_timer[2]
- mov ds,ax
- mov al,08H
- mov ah,25H
- int 21H
- cli
- mov dx,cs:word ptr old_prtsc_io
- mov ax,cs:word ptr old_prtsc_io[2]
- mov ds,ax
- mov al,05H
- mov ah,25H
- int 21H
- cli
- xor dx,dx
- xor ax,ax
- mov ds,ax
- mov al,60H
- mov ah,25H
- int 21H
- push cs
- pop es
- mov ah,4aH
- xor bx,bx
- int 21H
- jc err_exit
- mov ax,cs:[2ch]
- mov es,ax
- xor bx,bx
- mov ah,4ah
- int 21h
- jc err_exit
- mov si,offset cs:remove_msg
- call dspmsg
- jmp exit
- err_exit:
- mov si,offset cs:rem_err_msg
- call dspmsg
- jmp exit
-
- setabort:
- cli
- mov ax,cs
- mov ds,ax
- mov dx,offset new_prtsc_io
- mov al,05H
- mov ah,25H
- int 21H
- jmp exit
-
- control_int endp
-
- new_prtsc_io proc far
- sti ; Abort task via DOS terminate function
- mov ah,4cH
- int 21H
- iret
- new_prtsc_io endp
-
- location dw 0000H ;Upper-left corner of screen
- ipreg db 'CS:IP=',0
- flgreg db ' FLAGS=',0
- ssreg db ' SS=',0
- esreg db ' ES=',0
- dsreg db ' DS=',0
-
- initialize:
- xor di,di
- mov al,60H
- mov ah,35H
- int 21H
- cmp bx,0
- jne args
- inst:
- mov ah,0fh
- int 10h
- cmp al,07h
- jne color
- mov ax,0b000h
- jmp short setseg
- color:
- mov ax,0b800h
- setseg:
- mov cs:dspseg,ax
- inc di
- mov bx,cs
- mov ds,bx
- mov al,08H
- mov ah,35H
- int 21H
- mov word ptr old_timer,bx
- mov word ptr old_timer[2],es
-
- mov al,05H
- mov ah,35H
- int 21H
- mov word ptr old_prtsc_io,bx
- mov word ptr old_prtsc_io[2],es
-
- mov dx,offset control_int
- mov al,60H
- mov ah,25H
- int 21H
-
- mov si,offset initmsg
- call dspmsg
-
- args:
- mov bl,0ffH
- mov si,80H
- xor cx,cx
- mov cl,cs:[si]
- cmp cx,2
- jg nxtch
- jmp intdone
- nxtch:
- inc si
- cmp byte ptr cs:[si],'/'
- je decode_opt
- cont:
- loop nxtch
- jmp intdone
-
- decode_opt:
- inc si
- mov ah,cs:[si]
- cmp ah,'a'
- jl upcase
- sub ah,' '
- upcase:
- cmp ah,'R'
- je reset
- cmp ah,'D'
- je disp
- cmp ah,'S'
- je ip
- cmp ah,'F'
- je fuldsp
- cmp ah,'A'
- jne cont
- mov al,4
- jmp do_opt
-
- reset:
- mov al,0
- jmp do_opt
- disp:
- mov al,1
- jmp do_opt
- fuldsp:
- mov al,3
- jmp do_opt
- ip:
- mov al,2
- do_opt:
- int 60H
- xor bl,bl
- jmp cont
-
- intdone:
- cmp bl,0H
- jz nomsg
- mov si,offset options
- call dspmsg
- nomsg:
- cmp di,0
- je init_exit
- mov dx,offset initialize
- int 27H
-
- init_exit:
- mov ah,4cH
- int 21H
-
- initmsg: db 'Front Panel Display Now Resident'
- db 0dH,0aH,'$'
- options:
- db 0dH,0aH,'FPANEL Command Line Options:',0dH,0aH
- db '/r Removes FPANEL from Memory and Restores Timer(int 8)'
- db 0dH,0aH
- db ' and PrtSc(int 5) and User(int 60H) interrupts'
- db 0dH,0aH
- db '/d Display Selected Registers at Top of Screen'
- db 0dH,0aH
- db '/s Select CS:IP registers only (default selection)'
- db 0dH,0aH
- db '/f Select CS:IP FLAG SS ES DS Registers'
- db 0dH,0aH
- db '/a Program Abort function replaces PrtSc function'
- db 0dH,0aH,'$'
-
-
- cseg ends
- end start